Repository navigation
Conversation
CSV.parse with row_sep: "" kept emitting empty rows after the input, including when a quoted field contained a newline.
Regexp.new("") is //, so the parser treated every position as
the end of a row and never finished the input. An empty
separator is one row and does not match.
Fixes ruby#394
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
row_sep: ""is one row. The parser built that separator asRegexp.new(""), which is//, so every position counted as the end of a row and parsing never finished:An empty separator no longer matches. That input is one row. A field that contains a newline still round-trips, and the documented case with no newline is unchanged:
On csv 3.3.5, a fifth of a second of
CSV.parse("a,b\n1,2\n", row_sep: "")produced[["a", "b"], [], [], [], [], []]and was still going. After this change it returns one row.ruby run-test.rbis 536 tests, 4071 assertions.Fixes #394